package servletContext;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class CountUserListener implements HttpSessionListener {
	private int count=0;
	@Override
	public void sessionCreated(HttpSessionEvent arg0) {
		count++;
		System.out.println("sessionCreated");
		ServletContext sc = arg0.getSession().getServletContext();
		sc.setAttribute("count", count);
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent arg0) {
		count--;
		System.out.println("sessionDestroyed");
		ServletContext sc = arg0.getSession().getServletContext();
		sc.setAttribute("count", count);
	}

}
